//
//  NSString+Extension.m
//  WYWDownloader
//
//  Created by Mr.Run on 2017/11/8.
//  Copyright © 2017年 Mr.Run. All rights reserved.
//

#import "NSString+Extension.h"
#import <CommonCrypto/CommonDigest.h>

@implementation NSString (Extension)

-(NSString *)md5{
    
    const char *data = self.UTF8String;
    unsigned char md[CC_MD5_DIGEST_LENGTH];
    
    CC_MD5(data, (CC_LONG)strlen(data), md);
    
    NSMutableString *result = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2];
    for (int i=0; i<CC_MD5_DIGEST_LENGTH; i++) {
        [result appendFormat:@"%02x",md[i]];
    }
    NSLog(@"%s~~~%d~~~%@",__func__,__LINE__,result);
    return result;
}

@end
